Skip to content

Replace build.rs with link attributes#205

Merged
josephlr merged 1 commit intomasterfrom
link_attr
Feb 17, 2021
Merged

Replace build.rs with link attributes#205
josephlr merged 1 commit intomasterfrom
link_attr

Conversation

@newpavlov
Copy link
Member

@newpavlov newpavlov commented Feb 12, 2021

Closes #204.

iOS code already had link attributes. To be extra safe I would prefer for someone to verify that this change does not break iOS targets.

@newpavlov newpavlov requested a review from josephlr February 12, 2021 09:52
@Absolucy
Copy link

Absolucy commented Feb 16, 2021

I'm having issues related to note: ld: framework not found Security with iOS targets + LTO, so this seems like it'd actually fix things.

Can't test as my dep tree pulls in 0.1 and 0.2 of getrandom, though, so [patches.crates-io] doesn't work

Copy link
Member

@josephlr josephlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct. After reading the documentation for the cargo:rustc-link-lib=[KIND=]NAME instruction in build scripts, the #[link] attribute, and the -l rustc flag, I can confidently say that:

  • Adding "cargo:rustc-link-lib=framework=Security" to build.rs
  • Adding #[link(name = "Security", kind = "framework")] to an extern "C" block

do the exact same thing, namely passing -l framework=Security to rustc.

@josephlr josephlr merged commit c4a0004 into master Feb 17, 2021
@josephlr
Copy link
Member

Can't test as my dep tree pulls in 0.1 and 0.2 of getrandom, though, so [patches.crates-io] doesn't work

Does this mean you would also like to see this change backported to 0.1?

@Lokathor
Copy link

if 0.1 is getting new releases there's no reason to not also do this in 0.1

@newpavlov newpavlov deleted the link_attr branch February 17, 2021 09:25
takumi-earth pushed a commit to earthlings-dev/getrandom that referenced this pull request Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use link attributes on extern declarations rather than build.rs

4 participants